// -*- C++ -*-
-// $Id: babeldata.h,v 1.4 2010/02/14 05:33:36 robertl Exp $
+// $Id: babeldata.h,v 1.5 2010/02/15 02:57:00 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
upgradeCheckMethod(0),
upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0))),
installationUuid(QUuid::createUuid().toString()),
- checkUpgradeOnStart(true)
+ startupVersionCheck(true),
+ reportStatistics(true)
{
};
sg.addVarSetting(new IntSetting("app.upgradeCheckMethod", upgradeCheckMethod));
sg.addVarSetting(new DateTimeSetting("app.upgradeCheckTime", upgradeCheckTime));
sg.addVarSetting(new StringSetting("app.installationUuid", installationUuid));
+
+ // Global preferences.
+ sg.addVarSetting(new BoolSetting("app.startupVersionCheck", startupVersionCheck));
+ sg.addVarSetting(new BoolSetting("app.reportStatistics", reportStatistics));
+
}
static const int noType;
QString installationUuid;
// Global preferences.
- bool checkUpgradeOnStart;
+ bool startupVersionCheck;
+ bool reportStatistics;
};
// -*- C++ -*-
-// $Id: format.h,v 1.5 2010/02/14 05:33:37 robertl Exp $
+// $Id: format.h,v 1.6 2010/02/15 02:57:00 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
bool isDeviceFormat() const { return deviceFormat; };
bool isFileFormat() const { return fileFormat; };
+
bool isHidden() const { return hidden_; };
+ void setHidden(bool state) { hidden_ = state; };
void saveSettings(QSettings &settings);
void restoreSettings(QSettings &settings);
// -*- C++ -*-
-// $Id: mainwindow.cpp,v 1.15 2010/02/14 21:29:06 robertl Exp $
+// $Id: mainwindow.cpp,v 1.16 2010/02/15 02:57:00 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
//--- Restore from registry
restoreSettings();
- if (bd.checkUpgradeOnStart) {
+ if (bd.startupVersionCheck) {
upgrade = new UpgradeCheck(parent, formatList);
upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod,
- bd.upgradeCheckTime, bd.installationUuid);
+ bd.upgradeCheckTime, bd.installationUuid,
+ bd.reportStatistics);
}
}
ui.inputFormatCombo->clear();
for (int i=0; i<indices.size(); i++) {
int k = indices[i];
-fprintf(stderr, "%s/%d\n", qPrintable(formatList[k].getName()), formatList[k].isHidden());
if (!formatList[k].isHidden())
ui.inputFormatCombo->addItem(formatList[k].getDescription(), QVariant(k));
}
ui.inputFormatCombo->clear();
for (int i=0; i<indices.size(); i++) {
int k = indices[i];
-fprintf(stderr, "%s/%d\n", qPrintable(formatList[k].getName()), formatList[k].isHidden());
if (!formatList[k].isHidden())
ui.inputFormatCombo->addItem(formatList[k].getDescription(), QVariant(k));
}
//------------------------------------------------------------------------
void MainWindow::preferencesActionX()
{
- Preferences preferences(0, formatList);
+ Preferences preferences(0, formatList, bd);
preferences.exec();
+
+ // We may have changed the list of displayed formats. Resynchronize.
+ setWidgetValues();
}
// USA
-#include <QSettings>
#include "preferences.h"
class FormatListEntry : public QListWidgetItem {
Format& fmt_;
};
-Preferences::Preferences(QWidget* parent, QList<Format>& formatList) :
- formatList_(formatList)
+Preferences::Preferences(QWidget* parent, QList<Format>& formatList,
+ BabelData& bd) : QDialog(parent),
+ formatList_(formatList),
+ bd_(bd)
{
ui_.setupUi(this);
- // TODO: read from prefs.
- // ui_.startupCheck->setChecked(true);
+ ui_.startupCheck->setChecked(bd_.startupVersionCheck);
+ ui_.reportStatisticsCheck->setChecked(bd_.reportStatistics);
+
connect (ui_.buttonBox, SIGNAL(accepted()), this, SLOT(acceptClicked()));
connect (ui_.buttonBox, SIGNAL(rejected()), this, SLOT(rejectClicked()));
for (int i = 0; i < formatList_.size(); i++) {
FormatListEntry *item = new FormatListEntry(formatList[i]);
- ui_.enabledFormatsList->insertItem(0, item);
+ ui_.enabledFormatsList->addItem(item);
}
}
void Preferences::acceptClicked()
{
+ for (int i = 0; i < ui_.enabledFormatsList->count(); i++) {
+ QListWidgetItem* item = ui_.enabledFormatsList->item(i);
+ formatList_[i].setHidden(item->checkState() == Qt::Unchecked);
+ }
+
+ bd_.startupVersionCheck = ui_.startupCheck->isChecked();
+ bd_.reportStatistics = ui_.reportStatisticsCheck->isChecked();
accept();
}
// USA
#include "ui_preferences.h"
+
+#include "babeldata.h"
#include "format.h"
class Preferences : public QDialog {
Q_OBJECT
public:
- Preferences(QWidget* parent, QList<Format>& formatList);
+ Preferences(QWidget* parent, QList<Format>& formatList, BabelData& bd);
private:
QList<Format>& formatList_;
Ui_Preferences ui_;
+ BabelData& bd_;
private slots:
void enableAllClicked();
<rect>
<x>0</x>
<y>0</y>
- <width>777</width>
- <height>351</height>
+ <width>554</width>
+ <height>404</height>
</rect>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
<property name="currentIndex">
<number>1</number>
</property>
<property name="text">
<string>Check for newer version on start.</string>
</property>
- <property name="checked">
- <bool>true</bool>
- </property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="checkBox">
+ <widget class="QCheckBox" name="reportStatisticsCheck">
<property name="text">
<string>Anonymously report usage data.</string>
</property>
- <property name="checked">
- <bool>true</bool>
- </property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="enabledFormatsList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="sortingEnabled">
- <bool>true</bool>
+ <bool>false</bool>
</property>
</widget>
</item>
// -*- C++ -*-
-// $Id: setting.h,v 1.2 2009/09/02 19:05:27 robertl Exp $
+// $Id: setting.h,v 1.3 2010/02/15 02:57:00 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
#define SETTING_H
#include <QSettings>
+#include <QDate>
//------------------------------------------------------------------------
// -*- C++ -*-
-// $Id: upgrade.cpp,v 1.21 2010/02/14 21:29:06 robertl Exp $
+// $Id: upgrade.cpp,v 1.22 2010/02/15 02:57:00 robertl Exp $
/*
Copyright (C) 2009, 2010 Robert Lipe, robertlipe@gpsbabel.org
UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString ¤tVersionIn,
int checkMethod,
const QDateTime &lastCheckTime,
- const QString &installationUuid)
+ const QString &installationUuid,
+ bool reportStatistics)
{
currentVersion = currentVersionIn;
currentVersion.remove("GPSBabel Version ");
if (wc)
args += QString("&uc%1=wr/%2/%3").arg(j++).arg(formatName).arg(wc);
}
- if (j)
+ if (j && reportStatistics)
args += QString("&uc=%1").arg(j);
if (false && testing)
UpgradeCheck::updateStatus checkForUpgrade(const QString &babelVersion,
int upgradeCheckMethod,
const QDateTime &lastCheckTime,
- const QString &installationUuid
+ const QString &installationUuid,
+ bool reportStatistics
);
QDateTime getUpgradeWarningTime() {
return upgradeWarningTime;